package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SecurityActivity;
import com.ruoyi.system.service.ISecurityActivityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 安防附件Controller
 * 
 * @author ruoyi
 * @date 2021-07-22
 */
@RestController
@RequestMapping("/system/Security")
public class SecurityActivityController extends BaseController
{
    @Autowired
    private ISecurityActivityService securityActivityService;

    /**
     * 查询安防附件列表
     */
//    @PreAuthorize("@ss.hasPermi('system:activity:list')")
    @GetMapping("/list")
    public TableDataInfo list(SecurityActivity securityActivity)
    {
        startPage();
        List<SecurityActivity> list = securityActivityService.selectSecurityActivityList(securityActivity);
        return getDataTable(list);
    }

    /**
     * 导出安防附件列表
     */
//    @PreAuthorize("@ss.hasPermi('system:activity:export')")
    @Log(title = "安防附件", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SecurityActivity securityActivity)
    {
        List<SecurityActivity> list = securityActivityService.selectSecurityActivityList(securityActivity);
        ExcelUtil<SecurityActivity> util = new ExcelUtil<SecurityActivity>(SecurityActivity.class);
        return util.exportExcel(list, "activity");
    }

    /**
     * 获取安防附件详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:activity:query')")
    @GetMapping(value = "/{saId}")
    public AjaxResult getInfo(@PathVariable("saId") Long saId)
    {
        return AjaxResult.success(securityActivityService.selectSecurityActivityById(saId));
    }

    /**
     * 新增安防附件
     */
//    @PreAuthorize("@ss.hasPermi('system:activity:add')")
    @Log(title = "安防附件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SecurityActivity securityActivity)
    {
        return toAjax(securityActivityService.insertSecurityActivity(securityActivity));
    }

    /**
     * 修改安防附件
     */
//    @PreAuthorize("@ss.hasPermi('system:activity:edit')")
    @Log(title = "安防附件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SecurityActivity securityActivity)
    {
        return toAjax(securityActivityService.updateSecurityActivity(securityActivity));
    }

    /**
     * 删除安防附件
     */
//    @PreAuthorize("@ss.hasPermi('system:activity:remove')")
    @Log(title = "安防附件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{saIds}")
    public AjaxResult remove(@PathVariable Long[] saIds)
    {
        return toAjax(securityActivityService.deleteSecurityActivityByIds(saIds));
    }
}
